//index.js
//获取应用实例
var app = getApp()
Page({
	data: {
		root:'',
		siteroot:app.setting.siteroot,
		att_url:app.setting.att_url,
		account:app.setting.account,
		pagetitle:'找人代付' + '-' + app.setting.title,
		
	},
	onReady: function (){
	},
	onLoad: function (){
		var page=this;
		wx.setNavigationBarTitle({'title':page.data.pagetitle});
		var route=page.route;
		page.setData({
			route:route,
			apptitle:app.setting.title,
		});
		if(!app.plugin_name){
			var path=route.slice(0,-6).split('/');
			app.plugin_name=path.shift();
		}
		app.util.get(app.access,function(pagedata){
			console.log('peerpay');console.log(pagedata);	
			page.setData({
				pagedata:pagedata
			});
		});
	},
	settype: function (e) {
		var the=this;
		var pagedata=the.data.pagedata;
		var data = e.currentTarget.dataset;
		this.setData({
				'pagedata.item.type':data.type,
		});
		
	},
	setremark: function (e) {
		var the=this;
		var pagedata=the.data.pagedata;
		var remark = e.detail.value;
		this.setData({
				'pagedata.item.remark':remark,
		});
		
	},
	post:function(){
		var page=this
		var pagedata=page.data.pagedata
		app.util.post('jy_weishop/order.peerpay/post/',pagedata.item);
	},
	click:function(evt){
		//用户点击事件 data.func 为方法名，data.params 为调用参数！
		var data=evt.currentTarget.dataset;
		app.util[data.func](data.params);
	},
	onShareAppMessage: function (res) {
		var the = this
		var pagedata = the.data.pagedata
		if (res.from === 'button') {
		}
		var path='/jy_weishop/order/peerpay_pay/index?orderid='+pagedata.orderid;
		if(pagedata.fromuser){
			path +='&fromuser='+pagedata.fromuser;
		}
		return {
		  title: pagedata.sharedata.title,
		  path: path,
		  desc: pagedata.sharedata.desc,
		  success: function(res) {
		  },
		  fail: function(res) {
		  }
		}
	},
	onShareTimeline: function (res) {
		var the = this
		var pagedata = the.data.pagedata
		var query=app.access.query
		query +='&orderid='+pagedata.orderid;
		if(pagedata.fromuser){
			query +='&fromuser='+pagedata.fromuser;
		}
		query +='&isgoshare=1'
		return {
		  title: pagedata.sharedata.title,
		  query: query,
		  desc: pagedata.sharedata.desc,
		  success: function(res) {
		  },
		  fail: function(res) {
		  }
		}
	},
});